#include "Ketonal.h"
#include "KetonalSettings.h"

class window  : public Component
{
	Ketonal *k;
	KetonalSettings ketonalSettings;

	public:
		window() : Component (T("Ketonal"))
		{
	        setVisible (true);
			setAlwaysOnTop (true);
			setBounds (ketonalSettings.getRect());
			addToDesktop (ComponentPeer::windowIsTemporary);

			addAndMakeVisible (k = new Ketonal(&ketonalSettings));
		}
		~window()
		{
			ketonalSettings.setRect (getBounds());
			ketonalSettings.save();
			deleteAndZero (k);
		}

	    void closeButtonPressed()
	    {
			ketonalSettings.setRect (getBounds());
			JUCEApplication::quit();
		}

		void minimisationStateChanged (bool isNowMinimised)
		{
			if (isNowMinimised)
			{
			}
			else
			{
			}
			Logger::writeToLog (T("minimisationStateChanged"));
		}

		void paint (Graphics &g)
		{
			g.fillAll (Colours::white.withAlpha(0.6f));
			g.setColour (Colours::aliceblue.darker());
			g.drawRect (0,0,getWidth(),getHeight());
		}
};


class app : public JUCEApplication
{
    window *wnd;
	
	public:
	    app()
	    {
			wnd = 0;
		}
		~app()
		{
		}
	    void initialise (const String& commandLine)
	    {
			wnd = new window();
		}
		void shutdown()
		{
		    if (wnd != 0)
				delete wnd;
		}
		const String getApplicationName()
		{
	        return T("test");
	    }
		const String getApplicationVersion()
		{
	        return T("1.0");
	    }
		bool moreThanOneInstanceAllowed()
		{
	        return false;
		}
		void anotherInstanceStarted (const String& commandLine)
		{
		}
};

START_JUCE_APPLICATION (app)
